//
//  String_Kit.swift
//  
//
//  Created by xp on 2023/3/29.
//

import Foundation

public extension String {
    /// String has space or newlines.
    /// (字符串有空格或换行)
    var hasBlank: Bool {
        // whitespacesAndNewlines: 空格和换行符
        let n = trimmingCharacters(in: .whitespacesAndNewlines)
        return n.count != count
    }
    
    subscript(_ offset: Int) -> Character? {
        if offset >= count || offset < 0 {
            return nil
        }
        return self[index(startIndex, offsetBy: offset)]
    }
}
